<template>
	<view class="myaddress">
		<view v-for="(item, index) in addressList" :key="index" class="order_address">
			<view class="address_box">
				<view class="weizhi_icon">
					<text class="iconfont icon-dizhi" :style="'color:' + color"></text>
				</view>
				<view @click="choose(item)" class="middle">
					<view class="address_content">
						<view class="address_name">{{item[attr.address]}}{{item[attr.details]}}</view>
					</view>
					<view class="address_content">
						<view class="moren" v-if="item[attr.is_default] == 1">
							<text class="iconfont icon-moren" :style="'color:' + color"></text>
						</view>
						<view class="name">
							<text class="text1">{{item[attr.reciver_name] }}</text>
							<text class="phones">{{item[attr.mobile]}}</text>
						</view>
						
					</view>
				</view>
				<view class="caozuo">
					<template v-for="(btn,key) in buttons">
						<view class="del" @tap="del(item,index)" v-if="btn=='del'">
							<text class="iconfont icon-shanchu">删除</text>
						</view>
						<view class="edit" @tap="edit(item)" v-if="btn=='edit'">
							<text class="iconfont icon-bianji">编辑</text>
						</view>
					</template>
					
				</view>

			</view>
		</view>

	</view>
</template>


<script>
	export default {
		data() {
			return {

			};
		},
		props: {
			attr: {
				type: Object,
				default(rawProps) {
					return {
						is_default:'is_default',
						reciver_name:'reciver_name',
						mobile:'mobile',
						address:'address',
						details:'details'
					}
				}
				
			},
			color: {
				type: String,
				default: '#FF0000'
			},
			addressList: {
				type: Array,
				default: []
			},
			buttons: {
				type: Array,
				default: ['edit','del']
			}
		},
		methods: {
			edit(item) {
				this.$emit("edit", item)
			},
			choose(item) {
				this.$emit("choose", item)
			},
			del(item, index) {
				this.$emit("del", item)
			}
		}
	};
</script>


<style lang="scss" scoped>
	/*每个页面公共css */
	@import "./icon.css";

	.myaddress {
		padding: 10upx 4%;
		padding-bottom: 140upx;
		margin-top: 10upx;
	}

	.order_address {
		height: 180upx;
		width: 100%;
		background-color: #fff;
		border-radius: 10upx;
		position: relative;
		box-shadow: 0upx 0upx 10upx #ddd;
		margin-bottom: 20upx;
	}

	.order_address image {
		width: 100%;
		height: 100%;
		display: block;
		position: absolute;
		top: 0;
		left: 0;
		z-index: 10;
	}

	.address_box {
		width: 100%;
		height: 100%;
		display: block;
		z-index: 10;
		box-sizing: border-box;
		padding: 20upx;
		display: flex;
		align-items: center;
	}

	.weizhi_icon text {
		font-size: 40upx;
		margin-left: 10upx;
	}

	.middle{
		width: 100%;
	}
	.address_box .address_content {
		margin-left: 20upx;
	}

	.address_box .address_content .name {
		height: 60upx;
		line-height: 60upx;
	}

	.address_box .address_content .name .text1 {
		font-size: 26upx;
		font-weight: bold;
		color: #333;
		display: inline-block;
		margin-right: 20upx;
	}

	.phones {
		font-size: 24upx;
		color: #999;
		z-index: 0;
	}

	.address_box .address_name {
		font-size: 26upx;
		font-weight: bold;
		color: #333;
	}

	.noaddress {
		margin-left: 40upx;
		font-weight: bold;
		color: #333;
		font-size: 26upx;
	}

	.caozuo {
		   width: 26%;
	}
	.del{
		height: 50rpx;
		line-height: 50rpx;
	}
	.caozuo .del text {
		color: #FF0000;
	}
	.edit{
		height: 50rpx;
			line-height: 50rpx;
	}
	.caozuo view {
		
		font-size: 24upx;
		color: #666;
		margin-left: 30upx;
	}

	.caozuo view text {
		font-size: 24upx;
	}

	.moren {
		position: absolute;
		top: 0;
		left: 0;
	}

	.moren text {
		font-size: 60upx;
	}
</style>